﻿using System;
using System.Net.Mail;
using System.Net;

class SendEmail
{
    //const string SMTP_SERVER = "mbox.contact.bg"; - BTC Clients SMTP Sever
    const string SMTP_SERVER = "smtp.gmail.com";

    //nslookup -type=mx gmail.com - cmd to look up smtp server name
    //const string SMTP_SERVER = "mail.fmi.uni-sofia.bg";
    //const string SMTP_SERVER = "mail.uni-sofia.bg";

    static void Main()
    {
        try
        {
            // Create the message
            MailAddress fromAddress = new MailAddress("nikinikitest@gmail.com", "Niki");
            MailAddress toAddress = new MailAddress("n.vasilev.fmi@gmail.com", "NVasilev");

            MailMessage msg = new MailMessage(fromAddress, toAddress);
            msg.Subject = "Zdrasti ma!";
            msg.IsBodyHtml = true;
            msg.Body = @"<html><body><h1>Kako, dokaraha
			prasetata. Idvaj burzo!</h1></body></html>";

            // Attach some file to the message
            //Attachment attachment = new Attachment(@"C:\WINDOWS\Media\chimes.wav");
            //msg.Attachments.Add(attachment);

            // Send the message
            Console.WriteLine("Sending e-mail message...");
            SmtpClient client = new SmtpClient(SMTP_SERVER, 587);
            client.EnableSsl = true;
            client.DeliveryMethod = SmtpDeliveryMethod.Network;
            client.UseDefaultCredentials = false;
            client.Credentials = new NetworkCredential("nikinikitest@gmail.com", "nikiniki");

            client.Send(msg);
            Console.WriteLine("Mail sent.");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Unable to send message: {0}",
                              ex.ToString());
            Console.ReadLine();
        }
    }
}
